package chapter25;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/2/28 13:24
 */
public class CommonUseRegex {
    private static final Pattern zip_code_pattern = Pattern.compile("(?<![0-9])[0-9]{6}(?![0-9])");

    public static boolean isZipCode(String text) {
        return zip_code_pattern.matcher(text).matches();
    }

    public static void findZipCode(String text) {
        Matcher matcher = zip_code_pattern.matcher(text);
        while (matcher.find()) {
            System.out.println(matcher.group());
        }
    }

    public static void main(String[] args) {
        findZipCode("邮编 100013, 电话 1234556663");
    }
}
